package com.carleasoft.mps.cms.business.article.constants;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 * <p>Description: FlowStatus</p>
 * @since 2021/7/5
 * @author taoyujing
 */
public enum FlowStatus {

    CREATE(0,"创建文章，草稿"),
    TO_PROOFREADING(1,"等待校审"),
    TO_PUBLISH(2,"等待发布"),
    PUBLISH(3,"发布"),
    REVOCATION_PUBLISH(4,"撤销发布"),
    RETURN(5,"退回采编"),
    CANCEL(6,"取消提交");

    private Integer id;
    private String name;

    private FlowStatus(Integer id, String name) {
        this.id = id;
        this.name = name;
    }
    private FlowStatus(Integer id) {
        this.id = id;
    }

    private FlowStatus(String name) {
        this.name = name;
    }


    @JsonValue(value = true)
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @JsonValue
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }


    public static boolean isInclude(String name){
        boolean include = false;
        for (FlowStatus e: FlowStatus.values()){
            if(e.getName().equals(name)){
                include = true;
                break;
            }
        }
        return include;
    }

    public static String byName(Integer id){
            for (FlowStatus e: FlowStatus.values()){
                if(e.getId().equals(id)){
                   return e.getName();
                }
            }
            return null;
        }


    public static boolean isInclude(int key){
        boolean include = false;
        for (FlowStatus e: FlowStatus.values()){
            if(e.getId() == key){
                include = true;
                break;
            }
        }
        return include;
    }
}
